package vns.server;

import javax.jdo.PersistenceManager;

import vns.client.service.ObjectTypeTelephoneService;
import vns.server.domain.ObjectTypeTelephone;
import vns.shared.ObjectTypeTelephoneDTO;

import com.google.appengine.api.datastore.Key;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class ObjectTypeTelephoneServiceImpl extends RemoteServiceServlet 
			implements ObjectTypeTelephoneService{

	@Override
	public ObjectTypeTelephoneDTO Create(ObjectTypeTelephoneDTO opTelephoneDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeTelephone action=null;
		try{
			action=new ObjectTypeTelephone(opTelephoneDTO);
			pm.makePersistent(action);
		}finally{
			pm.close();
		}
		return action.toDTO();
	}

	@Override
	public ObjectTypeTelephoneDTO load(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeTelephoneDTO actionDTO=null;
		try{
			ObjectTypeTelephone action = pm.getObjectById(ObjectTypeTelephone.class,id);	
			actionDTO=action.toDTO();
		}finally{
			pm.close();
		}
		return actionDTO;
	}

	@Override
	public ObjectTypeTelephoneDTO Update(ObjectTypeTelephoneDTO opTelephoneDTO) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		ObjectTypeTelephone action=null;
		try{
			action=pm.getObjectById(ObjectTypeTelephone.class,opTelephoneDTO.getId());
			action.updatefromDTO(opTelephoneDTO);
		}finally{
			pm.close();
		}
		
		return action.toDTO();
	}

	@Override
	public boolean remove(Key id) {
		PersistenceManager pm=PMF.get().getPersistenceManager();
		try{
			ObjectTypeTelephone action= pm.getObjectById(ObjectTypeTelephone.class,id);
			if(action!=null){
				pm.deletePersistent(pm.getObjectById(ObjectTypeTelephone.class,id));
			}
		}finally{
			pm.close();
		}
		return true;
	}

}
